package com.jlz.actions.console.valuetype;

import org.apache.struts2.convention.annotation.Standard;
import org.springframework.beans.factory.annotation.Autowired;

import com.jlz.beans.def.ValuetypeBean;
import com.jlz.managers.def.Valuetypes;
import com.julewa.Client;
import com.julewa.db.BeanValidator;

@Standard(rest="valuetype.ID")
public class SaveAction {
	@Autowired Client client;
	@Autowired Valuetypes valuetypes;
	@Autowired ValuetypeBean valuetype;
	@Autowired BeanValidator validator;
	
	public String execute(){
		//
		if(!validator.checkColumns("valuetype", valuetype)){
			return "edit";
		}
		//
		if(valuetype.getID() == null){
			valuetypes.insert(valuetype);
		}else{
			valuetypes.update(valuetype);
		}
		return "edit";
	}

	public ValuetypeBean getValuetype() {
		return valuetype;
	}

	public void setValuetype(ValuetypeBean valuetype) {
		this.valuetype = valuetype;
	}
	
	
}
